package homework1.client;

import homework1.utils.Tool;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

/**
 * 用户服务业务逻辑类
 *
 * @author jian
 * @date 2024/01/09 00:48
 **/
public class ClientService {
    public static final String dirPath = "D:\\java\\program\\study\\集训\\parent\\javav2.0\\src\\main\\java\\homework1\\client\\files\\";


    public static void sendJsonOrXml(Socket socket){
        OutputStream outputStream = null;
        Scanner sc = new Scanner(System.in);
        try {
            ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
            // 发送文件类型（XML或JSON）
            System.out.print("输入文件名以发送文件：");
            String input = sc.next();
            String filePath = dirPath + input;
            if (Tool.fileIsExist(filePath)){
                Tool.sendEncryptedFile(oos, filePath);
            }
            // 获取输入流
            InputStream inputStream = socket.getInputStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        } catch (IOException e) {
            throw new RuntimeException(e);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }


}
